package org.tgcloud.group.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.tgcloud.group.entity.MjOrder;
import org.tgcloud.group.entity.SysDate;
import org.tgcloud.group.web.controller.dto.order.*;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Author: zhy
 * @Created: 2025-09-01-下午2:48
 * @Description: ${description}
 */
public interface MjOrderMapper extends BaseMapper<MjOrder> {
    int deleteByPrimaryKey(Integer id);

//    int insert(MjOrder record);

    int insertSelective(MjOrder record);

    MjOrder selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(MjOrder record);

    int updateByPrimaryKey(MjOrder record);

    int updateNumAndPriceByOrderId(@Param("orderId") Integer id, @Param("orderNum") Integer orderGoodNum,
                                   @Param("orderPrice") BigDecimal orderGoodPrice, @Param("goodRealTotalPrice") BigDecimal goodRealTotalPrice);

    int updateCateAndBrandByOrderId(@Param("orderId") Integer orderId, @Param("cateIds") String cateGoryIds, @Param("brands") String brands);

    int updateStatusByOrderId(@Param("orderId") Integer orderId, @Param("status") short status);

    int updateIsPushByOrderId(@Param("orderId") Integer orderId, @Param("isPush") short isPush);

    List<ManagerOrderDTO> selectListByKeyword(@Param("keyword") String keyword, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                              @Param("status") Short status, @Param("managerUserId") Integer managerUserId, @Param("projectId") Integer projectId,
                                              @Param("executionProgressId") Integer executionProgressId, @Param("arrivalProgressId") Integer arrivalProgressId,
                                              @Param("arrivalWarehouseId") Integer arrivalWarehouseId, @Param("isDiscount") Short isDiscount,
                                              @Param("permissionId") Integer permissionId, @Param("businessId") Integer businessId, @Param("areaId") String areaId,
                                              @Param("cateIds") String cateIds, @Param("startPrice") BigDecimal startPrice, @Param("endPrice") BigDecimal endPrice,
                                              @Param("statusList") String[] statusList, @Param("statusType") Short statusType, @Param("fileType") Short fileType,
                                              @Param("isTimeOut") Short isTimeOut, @Param("parentId") Integer parentId, @Param("isParentOrder") Short isParentOrder,
                                              @Param("orderGo") Integer orderGo, @Param("pushSureCheckStartTime") Long pushSureCheckStartTime,
                                              @Param("pushSureCheckEndTime") Long pushSureCheckEndTime, @Param("allHolidayDateList") List<SysDate> allHolidayDateList,
                                              @Param("showSubOrderType") Short showSubOrderType);

    List<ManagerOrderDTO> selectAppOrderList(@Param("userId") Integer userId, @Param("userType") Short userType,
                                             @Param("createUserId") Integer createUserId, @Param("keyword") String keyword,
                                             @Param("area") String area, @Param("cateName") String cateName,
                                             @Param("permissionUsername") String permissionUsername, @Param("status") Short status,
                                             @Param("bussinessUsername") String bussinessUsername, @Param("startTime") Date startTime,
                                             @Param("endTime") Date endTime, @Param("statuses") List statuses,
                                             @Param("userSearch") String userSearch);

    List<ManagerOrderDTO> selectChildListByKeyword(@Param("keyword") String keyword, @Param("startTime") Date startTime, @Param("endTime") Date endTime,
                                                   @Param("status") Short status, @Param("managerUserId") Integer managerUserId, @Param("projectId") Integer projectId,
                                                   @Param("executionProgressId") Integer executionProgressId, @Param("arrivalProgressId") Integer arrivalProgressId,
                                                   @Param("arrivalWarehouseId") Integer arrivalWarehouseId, @Param("isDiscount") Short isDiscount,
                                                   @Param("permissionId") Integer permissionId, @Param("businessId") Integer businessId, @Param("areaId") String areaId,
                                                   @Param("cateIds") String cateIds, @Param("startPrice") BigDecimal startPrice, @Param("endPrice") BigDecimal endPrice,
                                                   @Param("statusList") String[] statusList, @Param("statusType") Short statusType, @Param("fileType") Short fileType,
                                                   @Param("isTimeOut") Short isTimeOut, @Param("parentId") Integer parentId, @Param("isParentOrder") Short isParentOrder);

    List<ManagerOrderDTO> selectAppListByUserId(@Param("userId") Integer userId, @Param("userType") Short userType,
                                                @Param("createUserId") Integer createUserId, @Param("keyword") String keyword,
                                                @Param("area") String area, @Param("cateName") String cateName,
                                                @Param("permissionUsername") String permissionUsername, @Param("status") Short status,
                                                @Param("bussinessUsername") String bussinessUsername, @Param("startTime") Date startTime,
                                                @Param("endTime") Date endTime, @Param("statuses") List statuses);

    ManagerOrderDTO selectMsgByOrderId(@Param("orderId") Integer orderId);

    int updateStatusByOrderIds(@Param("ids") String[] split, @Param("status") short status);

    String selectWinBiddingName(@Param("orderId") Integer orderId);

    int updateChannelUserIdsByOrderId(@Param("orderId") Integer orderId, @Param("userIds") String userIds);

    int updatePushUsersByOrderId(@Param("orderId") Integer orderId, @Param("userIds") String userIds);

    int updateBlindBoxByOrderId(@Param("orderId") Integer orderId, @Param("price") BigDecimal blindBoxPrice,
                                @Param("takeAllStatus") Short takeAllStatus, @Param("userId") int userId);

    int updateTwoBlindBoxByOrderId(@Param("orderId") Integer orderId, @Param("price") BigDecimal blindBoxPrice,
                                   @Param("takeAllStatus") Short takeAllStatus, @Param("userId") int userId);

    int updateBiddingOneEndTimeByOrderId(@Param("endTime") Date endTime, @Param("orderId") Integer orderId);

    List<MjOrder> selectTaskList();

    int selectCountOrder(@Param("time") Date time, @Param("areaId") Integer areaId);

    int selectGroupCountOrder(@Param("time") Date time, @Param("groupId") Integer groupId);

    int updateNoPushUsersByOrderId(@Param("orderId") Integer id);

    int updateCheckMsgByOrderId(@Param("orderId") Integer orderId, @Param("cashPrice") BigDecimal cashPrice, @Param("costPrice") String costPrice,
                                @Param("remark") String remark);

    int updateStartTwoBidding(@Param("orderId") Integer orderId, @Param("userId") int userId, @Param("endTime") String endTime);

    int updateCostByOrderId(@Param("orderId") Integer orderId, @Param("estimatedCost") BigDecimal estimatedCost, @Param("actualCost") BigDecimal actualCost,
                            @Param("innerPrice") BigDecimal innerPrice, @Param("blindRealPrice") BigDecimal blindRealPrice,
                            @Param("saleRealPrice") BigDecimal saleRealPrice, @Param("projectRealPrice") BigDecimal projectRealPrice,
                            @Param("estimatedSelfMediaCost") BigDecimal estimatedSelfMediaCost, @Param("estimatedExternalMediaCost") BigDecimal estimatedExternalMediaCost,
                            @Param("actualSelfMediaCost") BigDecimal actualSelfMediaCost, @Param("actualExternalMediaCost") BigDecimal actualExternalMediaCost);

    int updateCheckStatusByOrderIds(@Param("ids") String[] split, @Param("status") short status);

    List<MjOrder> selectMonthHomeListByStartTimeAndEndTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    List<MjOrder> selectYearHomeListByStartTimeAndEndTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    int updateBrandsByProjectId(@Param("id") Integer id, @Param("brands") String brands);

    List<MjOrder> selectNeedUpdateTask(@Param("time") Long time);

    int updateIsSubmitCheckById(@Param("orderId") Integer orderId, @Param("checkUserIds") String checkUserIds);

    int updatePushChannelUserIdsByOrderId(@Param("pushChannelUserIds") String userIds, @Param("orderId") Integer orderId);

    int updateBiddingFirstUserIdsById(@Param("orderId") Integer orderId, @Param("userIds") String userIds);

    int updateBiddingSecondUserIdsById(@Param("orderId") Integer orderId, @Param("userIds") String userIds);

    int updateRefuseReasonById(@Param("orderId") Integer orderId, @Param("reason") String reason);

    List<MjOrder> selectListByProjectId(@Param("projectId") Integer id);

    List<MjOrder> selectNoSubListByProjectId(@Param("projectId") Integer id);

    List<MjOrder> selectSureListByProjectId(@Param("projectId") int projectId);

    int updateRealPriceById(@Param("orderId") Integer orderId, @Param("blindBoxRealPrice") BigDecimal blindBoxRealPrice,
                            @Param("saleRealPrice") BigDecimal saleRealPrice, @Param("totalPrice") BigDecimal totalPrice,
                            @Param("realRemark") String realRemark);

    List<MjOrder> selectTestList(@Param("projectIds") String[] ids);

    List<OtherOrderListDTO> selectOtherOrderByProjectId(@Param("projectId") Integer projectId, @Param("orderId") Integer orderId, @Param("parentId") Integer parentId);

    List<ParentOrderDTO> selectParentOrderList(@Param("parentId") Integer parentId);

    List<OtherOrderListDTO> selectOtherOrderByProjectIdAndChannelUserId(@Param("projectId") Integer projectId, @Param("orderId") Integer orderId,
                                                                        @Param("userId") Integer userId);

    int updateStatusByProjectId(@Param("projectId") Integer projectId, @Param("status") short status);

    int updateResettingOrder(@Param("orderId") Integer orderId);

    MjOrder selectOneMsgByProjectId(@Param("projectId") Integer id);

    List<MjOrder> selectOrderByProjectId(@Param("projectId") Integer id);

    int updateResettingOrderTime(@Param("orderId") Integer orderId);

    MjOrder selectMsgByBrandId(@Param("brandId") Integer id);

    MjOrder selectHasAddByProjectId(@Param("projectId") Integer projectId);

    List<MjOrder> selectListTest();

    List<MjOrder> selectListTest2();

    List<MjOrder> selectTimeOutList(@Param("twoMonthsAgoDate") Date twoMonthsAgoDate);

    List<ManagerOrderDTO> selectAppChildOrderList(@Param("userId") Integer userId, @Param("parentId") Integer parentId);

    int updateLastUserId(@Param("orderId") Integer orderId);

    int clearSecondBiddingPrice(@Param("orderId") Integer orderId);

    int updateReset(@Param("orderId") Integer orderId);

    int updateIsTimeOut(@Param("orderId") Integer orderId, @Param("isTimeOut") Short isTimeOut);

    int updateIsHasChild(@Param("orderId") Integer orderId, @Param("isHasChild") Short isHasChild);

    int updateCheckCostPrice(@Param("orderId") Integer orderId, @Param("checkCostPrice") String checkCostPrice);

    int updateCheckCashPrice(@Param("orderId") Integer orderId, @Param("checkCashPrice") BigDecimal checkCashPrice);

    List<TreeOrderListDTO> selectChildOrder(@Param("parenOrderId") Integer parenOrderId);

    TreeOrderListDTO selectChildNoComplete(@Param("parenOrderId") Integer parenOrderId);

    int updateStatusByParentId(@Param("parentId") Integer parentId, @Param("status") Short status);

    int updateEndTime(@Param("orderId") Integer orderId, @Param("endTime") Date endTime);

    int resetExpectPrice(@Param("orderId") Integer orderId);

    int updateOrderUseAndExpectPrice(@Param("orderId") Integer orderId, @Param("useType") Integer useType, @Param("expectPrice") BigDecimal expectPrice);

    List<MjOrder> selectTestListByFileType(@Param("fileType") int fileType);

    List<Integer> selectOtherIdList(@Param("orderId") Integer orderId, @Param("parentId") Integer parentId);

    int updatePushSureCheckTimeById(@Param("orderId") Integer id);

    int updatePushUserHandleDiffTimeById(@Param("time") Long holidayNumByTime, @Param("orderId") Integer id);

    int updateInnerPriceAndActualCostById(@Param("id") Integer id, @Param("innerPrice") BigDecimal innerPrice,
                                          @Param("actualCost") BigDecimal actualCost, @Param("actualSelfMediaCost") BigDecimal actualSelfMediaCost,
                                          @Param("actualExternalMediaCost") BigDecimal actualExternalMediaCost,
                                          @Param("estimatedCost") BigDecimal estimatedCost, @Param("estimatedSelfMediaCost") BigDecimal estimatedSelfMediaCost,
                                          @Param("estimatedExternalMediaCost") BigDecimal estimatedExternalMediaCost);

    int updateTotalPriceByOrderId(@Param("id") Integer orderId, @Param("totalPrice") BigDecimal totalPrice);

    int updateSomePriceByProjectId(@Param("projectId") Integer projectId, @Param("innerPrice") BigDecimal innerPrice,
                                   @Param("saleRealPrice") BigDecimal saleRealPrice, @Param("estimatedCost") BigDecimal estimatedCost,
                                   @Param("actualCost") BigDecimal actualCost,
                                   @Param("estimatedSelfMediaCost") BigDecimal estimatedSelfMediaCost, @Param("estimatedExternalMediaCost") BigDecimal estimatedExternalMediaCost,
                                   @Param("actualSelfMediaCost") BigDecimal actualSelfMediaCost, @Param("actualExternalMediaCost") BigDecimal actualExternalMediaCost);

    int updatePushSureCheckTypeById(@Param("orderId") Integer orderId);

    List<MjOrder> selectAllPushSureCheckTypeList(@Param("split") String[] split);

    List<MjOrder> selectAllParentOrderList();

    List<MjOrder> selectSubOrderByParentOrderId(@Param("parentOrderId") Integer id);

    int updateOrderExpectPrice(@Param("orderId") Integer id, @Param("expectPrice") BigDecimal expectPrice);

    List<MjOrder> selectTestHasChildList();

    List<MjOrder> selectOrderNoChildListByProjectId(@Param("projectId") Integer id);

    List<OrderBriefDTO> selectBriefHasBiddingListByProjectIdAndNoOrderId(@Param("projectId") Integer projectId, @Param("noOrderId") Integer noOrderId);

    int updateLastUserIdById(@Param("orderId") Integer orderId, @Param("lastUserId") Integer lastUserId);

    int updateRealTotalPriceById(@Param("orderId") Integer orderId, @Param("realTotalPrice") BigDecimal goodRealTotalPrice);

    int updateResourcesRemarkByProjectId(@Param("projectId") Integer projectId, @Param("resourcesRemark") String resourcesRemark);

    List<ManagerOrderDTO> selectAppCEOOrderList(@Param("keyword") String keyword,
                                                @Param("area") String area, @Param("cateName") String cateName,
                                                @Param("permissionUsername") String permissionUsername, @Param("status") Short status,
                                                @Param("bussinessUsername") String bussinessUsername, @Param("startTime") Date startTime,
                                                @Param("endTime") Date endTime, @Param("statuses") List<String> statuses,
                                                @Param("userSearch") String userSearch);

    List<ManagerOrderDTO> selectAppCEOChildOrderList(@Param("userId") Integer userId, @Param("parentId") Integer parentId);
}